package com.lc202309;

/**
 * Description:
 *
 * @Create 2023/9/1 23:24
 * @Version 1.0
 */
public class Solution58 {
    public int lengthOfLastWord(String s) {
        int index = 0;
        int length = s.length();
        for (int i = 0; i < length; i++) {
            if (index == 0 && s.charAt(length - i - 1) == ' ') {
                continue;
            }
            if (s.charAt(length - i - 1) == ' ') {
                return index;
            }
            index++;
        }
        return index;
    }
}
